package com.runvp.service.convert;

import com.runvp.common.model.vo.goods.BizRechargePackageItemVO;
import com.runvp.service.biz.domain.BizRechargePackageItem;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 充值选项对象属性转换
 * @author xukk
 */
@Component
public class BizRPIConvert {


    /**
     * to vo list
     * @param sources
     * @return list
     */
    public List<BizRechargePackageItemVO> convertVos(List<BizRechargePackageItem> sources){
        List<BizRechargePackageItemVO> targets = new ArrayList<>();
        if(CollectionUtils.isEmpty(sources)){
            return targets;
        }
        for(BizRechargePackageItem source:sources){
            targets.add(convertVO(source));
        }
        return targets;
    }
    /**
     * to do list
     * @param sources
     * @return list
     */
    public List<BizRechargePackageItem> convertEntities(List<BizRechargePackageItemVO> sources){
        List<BizRechargePackageItem> targets = new ArrayList<>();
        if(CollectionUtils.isEmpty(sources)){
            return targets;
        }
        for(BizRechargePackageItemVO source:sources){
            targets.add(convertEntity(source));
        }
        return targets;
    }
    /**
     * to  BizGoodsPriceVO
     * @param source
     * @return target
     */
    public BizRechargePackageItemVO convertVO(BizRechargePackageItem source){
        BizRechargePackageItemVO target = new BizRechargePackageItemVO();
        BeanUtils.copyProperties(source,target);
        return target;
    }

    /**
     * to  BizGoodsPrice
     * @param source
     * @return target
     */
    public BizRechargePackageItem convertEntity(BizRechargePackageItemVO source){
        BizRechargePackageItem target = new BizRechargePackageItem();
        BeanUtils.copyProperties(source,target);
        return target;
    }
}
